home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / jnos110g.zip / CONFIG.C < prev    next >
C/C++ Source or Header  |  1994-08-26  |  34KB  |  1,315 lines

  1. /* A collection of stuff heavily dependent on the configuration info
  2.  * in config.h. The idea is that configuration-dependent tables should
  3.  * be located here to avoid having to pepper lots of .c files with #ifdefs,
  4.  * requiring them to include config.h and be recompiled each time config.h
  5.  * is modified.
  6.  *
  7.  * Copyright 1991 Phil Karn, KA9Q
  8.  */
  9.  /* Mods by PA0GRI */
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #ifdef MSDOS
  14. #include <conio.h>
  15. #endif
  16. #include "global.h"
  17. #include "config.h"
  18. #include "mbuf.h"
  19. #include "timer.h"
  20. #include "proc.h"
  21. #include "iface.h"
  22. #include "ip.h"
  23. #include "tcp.h"
  24. #include "udp.h"
  25. #ifdef  ARCNET
  26. #include "arcnet.h"
  27. #endif
  28. #include "lapb.h"
  29. #include "ax25.h"
  30. #include "enet.h"
  31. #include "kiss.h"
  32. #include "netrom.h"
  33. #include "nr4.h"
  34. #include "pktdrvr.h"
  35. #include "ppp.h"
  36. #include "slip.h"
  37. #include "arp.h"
  38. #include "icmp.h"
  39. #include "hardware.h"   /***/
  40. #include "smtp.h"
  41. #include "usock.h"
  42. #include "cmdparse.h"
  43. #include "commands.h"
  44. #include "mailbox.h"
  45. #include "mailcli.h"
  46. #include "ax25mail.h"
  47. #include "nr4mail.h"
  48. #include "tipmail.h"
  49. #include "bootp.h"
  50. #include "daemon.h"
  51. #include "slhc.h"
  52. #include "rspf.h"
  53. #include "main.h"
  54.  
  55. static int dostart __ARGS((int argc,char *argv[],void *p));
  56. static int dostop __ARGS((int argc,char *argv[],void *p));
  57. static void network __ARGS((int,void *,void *));
  58.  
  59. #ifdef  NNTPS
  60. extern int donntpcli __ARGS((int argc,char *argv[],void *p));
  61. extern int nntp0 __ARGS((int argc,char *argv[],void *p));
  62. extern int nntp1 __ARGS((int argc,char *argv[],void *p));
  63. #endif
  64.  
  65. #ifdef  CONVERS
  66. int conv0 __ARGS((int argc,char *argv[],void *p));
  67. int conv1 __ARGS((int argc,char *argv[],void *p));
  68. #endif
  69.  
  70. #ifdef RLOGINSERVER
  71. int rlogin0 __ARGS((int argc,char *argv[],void *p));
  72. int rlogin1 __ARGS((int argc,char *argv[],void *p));
  73. #endif
  74.  
  75. #ifdef  AX25
  76. static void axip __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  77. char *dest,struct mbuf *bp,int mcast));
  78. static void axarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  79. char *dest,struct mbuf *bp,int mcast));
  80. static void axrarp __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  81. char *dest,struct mbuf *bp,int mcast));
  82. static void axnr __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  83. char *dest,struct mbuf *bp,int mcast));
  84. #endif
  85.  
  86. struct mbuf *Hopper;
  87. unsigned Nsessions = NSESSIONS;
  88.  
  89. /* Free memory threshold, below which things start to happen to conserve
  90.  * memory, like garbage collection, source quenching and refusing connects
  91.  */
  92. int32 Memthresh = MTHRESH;
  93.  
  94. #ifndef LINUX
  95. int Nibufs = NIBUFS;            /* Number of interrupt buffers */
  96. unsigned Ibufsize = IBUFSIZE;   /* Size of each interrupt buffer */
  97. #endif
  98.  
  99. /* Transport protocols atop IP */
  100. struct iplink Iplink[] = {
  101.     TCP_PTCL,       tcp_input,
  102.     UDP_PTCL,       udp_input,
  103.     ICMP_PTCL,      icmp_input,
  104. #ifdef ENCAP
  105.     IP_PTCL,        ipip_recv,
  106.     IP4_PTCL,       ipip_recv,
  107. #endif
  108. #ifdef  AXIP
  109.     AX25_PTCL,      axip_input,
  110. #endif
  111. #ifdef  RSPF
  112.     RSPF_PTCL,      rspf_input,
  113. #endif  /* RSPF */
  114.     0,              0
  115. };
  116.  
  117. /* Transport protocols atop ICMP */
  118. struct icmplink Icmplink[] = {
  119.     TCP_PTCL,       tcp_icmp,
  120.     0,              0
  121. };
  122.  
  123. /* ARP protocol linkages */
  124. struct arp_type Arp_type[NHWTYPES] = {
  125. #ifdef  NETROM
  126.     AXALEN, 0, 0, 0, 0, NULLCHAR, pax25, setcall,   /* ARP_NETROM */
  127. #else
  128.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  129. #endif
  130.  
  131. #ifdef  ETHER
  132.     EADDR_LEN,IP_TYPE,ARP_TYPE,REVARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  133. #else
  134.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  135. #endif
  136.  
  137.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_EETHER */
  138.  
  139. #ifdef  AX25
  140.     AXALEN, PID_IP, PID_ARP, PID_RARP, 10, Ax25multi[0], pax25, setcall,
  141. #else
  142.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_AX25 */
  143. #endif
  144.  
  145.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_PRONET */
  146.  
  147.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_CHAOS */
  148.  
  149.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_IEEE802 */
  150.  
  151. #ifdef  ARCNET
  152.     AADDR_LEN, ARC_IP, ARC_ARP, 0, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  153. #else
  154.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,
  155. #endif
  156.  
  157.     0, 0, 0, 0, 0, NULLCHAR,NULL,NULL,              /* ARP_APPLETALK */
  158. };
  159.  
  160. #ifdef  AX25
  161. /* Linkage to network protocols atop ax25 */
  162. struct axlink Axlink[] = {
  163.     PID_IP,         axip,
  164.     PID_ARP,        axarp,
  165. #ifdef RARP
  166.     PID_RARP,   axrarp,
  167. #endif
  168. #ifdef  NETROM
  169.     PID_NETROM,     axnr,
  170. #endif
  171.     PID_NO_L3,      axnl3,
  172.     0,              NULL,
  173. };
  174. #endif
  175.  
  176. #ifdef  MAILCLIENT
  177. struct daemon Mailreaders[] = {
  178. #ifdef  POP2CLIENT
  179.     "POP2",         2048,   pop2_job,
  180. #endif
  181. #ifdef  POP3CLIENT
  182.     "POP3",         2048,   pop3_job,
  183. #endif
  184.     NULLCHAR
  185. };
  186. #endif
  187.  
  188. #ifndef BOOTP
  189. int WantBootp = 0;
  190.  
  191. int
  192. bootp_validPacket(ip,bpp)
  193. struct ip *ip;
  194. struct mbuf **bpp;
  195. {
  196.     return 0;
  197. }
  198. #endif
  199.  
  200. #ifdef  MAILBOX
  201. void (*Listusers) __ARGS((int s)) = listusers;
  202. #else
  203. void (*Listusers) __ARGS((int s)) = NULL;
  204. #endif
  205.  
  206. #ifdef ETHER
  207. #define NWSTACK 2048
  208. #else
  209. #define NWSTACK 1024
  210. #endif
  211.  
  212. /* daemons to be run at startup time */
  213. struct daemon Daemons[] = {
  214.     "killer",       1024,   killer,
  215.     "timer",        1024,   timerproc,
  216.     "network",      NWSTACK,network,
  217.     "keyboard",     512,    keyboard,
  218. #ifndef UNIX
  219. #ifdef CONVERS
  220.     "gcollect",     512,    gcollect,
  221. #else
  222.     "gcollect",     256,    gcollect,
  223. #endif
  224. #endif
  225.     NULLCHAR,       0,      NULLVFP
  226. };
  227.  
  228. struct iftype Iftypes[] = {
  229.     /* This entry must be first, since Loopback refers to it */
  230.     "None",         NULL,           NULL,           NULL,
  231.     NULL,           CL_NONE,        0,
  232.  
  233. #ifdef  AX25
  234.     "AX25",         ax_send,        ax_output,      pax25,
  235.     setcall,        CL_AX25,        AXALEN,
  236. #endif
  237.  
  238. #ifdef  SLIP
  239.     "SLIP",         slip_send,      NULL,           NULL,
  240.     NULL,           CL_NONE,        0,
  241. #endif
  242.  
  243. #ifdef  ETHER
  244.     /* Note: NULL is specified for the scan function even though
  245.      * gether() exists because the packet drivers don't support
  246.      * address setting.
  247.      */
  248.     "Ethernet",     enet_send,      enet_output,    pether,
  249.     NULL,           CL_ETHERNET,    EADDR_LEN,
  250. #endif
  251.  
  252. #ifdef  NETROM
  253.     "NETROM",       nr_send,        NULL,           pax25,
  254.     setcall,        CL_NETROM,      AXALEN,
  255. #endif
  256.  
  257. #ifdef  SLFP
  258.     "SLFP",         pk_send,        NULL,           NULL,
  259.     NULL,           CL_NONE,        0,
  260. #endif
  261.  
  262. #ifdef  PPP
  263.     "PPP",          ppp_send,       ppp_output,     NULL,
  264.     NULL,           CL_PPP,         0,
  265. #endif
  266.  
  267.     NULLCHAR
  268. };
  269.  
  270. /* Command lookup and branch tables */
  271. struct cmds DFAR Cmds[] = {
  272.     /* The "go" command must be first */
  273.     "",             go,             0, 0, NULLCHAR,
  274. #ifndef AMIGA
  275. #ifdef SHELL
  276.     "!",            doshell,        0, 0, NULLCHAR,
  277. #endif
  278. #endif
  279. #ifdef FTPSESSION
  280.     "abort",    doabort,    0, 0, NULLCHAR,
  281. #endif
  282. #ifdef AMIGA
  283.     "amiga",        doamiga,        0, 0, NULLCHAR,
  284. #endif
  285. #if defined MAC && defined APPLETALK
  286.     "applestat",    doatstat,       0,      0, NULLCHAR,
  287. #endif
  288. #if defined AX25 || defined ETHER || defined APPLETALK
  289.     "arp",          doarp,          0, 0, NULLCHAR,
  290. #endif
  291. #ifdef ASY
  292.     "asystat",      doasystat,      0, 0, NULLCHAR,
  293. #endif
  294. #ifdef ATCMD
  295.     "at",       doat,       0, 0, NULLCHAR,
  296. #endif
  297.     "attach",       doattach,       0, 2,
  298.     "attach <hardware> <hw specific options>",
  299. #ifdef TTYLINKSERVER
  300.     "attended",     doattended,     0, 0, NULLCHAR,
  301. #endif
  302. #ifdef  AX25
  303. #ifdef AUTOROUTE
  304.     "autoroute",doax25autoroute, 0, 0, NULLCHAR,
  305. #endif /* AUTOROUTE */
  306.     "ax25",     doax25,     0, 0, NULLCHAR,
  307. #endif /* AX25 */
  308. #ifdef BBSSESSION
  309.     "bbs",      dotelnet,   1024, 0, NULLCHAR,
  310. #endif
  311. #ifdef  BOOTP
  312.     "bootp",    dobootp,    0, 0, NULLCHAR,
  313.     "bootpd",       bootpdcmd,      0, 0, NULLCHAR,
  314. #endif
  315. #ifdef BPQ
  316.     "bpqstat",  dobpqstat,  0,  0,  NULLCHAR,
  317. #endif
  318. #ifdef RLINE
  319.     "bulletin", dombrline,  0, 0, NULLCHAR,
  320. #endif
  321. /* This one is out of alpabetical order to allow abbreviation to "c" */
  322. #ifdef AX25SESSION
  323.     "connect",  doconnect,  1024, 3,
  324.     "connect <interface> <callsign>",
  325. #endif
  326. #if defined CALLCLI || defined SAMCALLB || defined QRZCALLB
  327.     "callbook", docallbook, 1024, 2, "callbook CALLSIGN",
  328. #endif
  329. #if defined(CALLSERVER) || defined(CALLCLI) || defined SAMCALLB || defined QRZCALLB
  330.     "callserver2", docallserver, 0, 0, NULLCHAR,
  331. #endif
  332. #if !defined(UNIX) && !defined(AMIGA)
  333. #ifdef DOSCMD
  334.     "cd",       docd,       0, 0, NULLCHAR,
  335. #endif
  336. #ifdef CALLSERVER
  337.     "cdrom", docdrom, 0, 0, NULLCHAR,
  338. #endif
  339. #endif
  340.     "close",        doclose,        0, 0, NULLCHAR,
  341.     "cls",  (int (*) ())    clrscr,      0, 0, NULLCHAR,
  342. #ifdef ASY
  343.     "comm",     doasycomm,  0, 3,"comm <interface> <text-string>",
  344. #endif
  345. #ifdef CONVERS
  346.     "convers",  doconvers,  0,  0, NULLCHAR,
  347. #endif
  348. #ifdef DOSCMD
  349.     "copy",     docopy,     0, 3,"copy <file> <newfile>",
  350. #endif
  351. /* This one is out of alpabetical order to allow abbreviation to "d" */
  352. #ifdef SESSIONS
  353.     "disconnect",   doclose,    0, 0, NULLCHAR,
  354. #endif
  355. #ifndef AMIGA
  356. #ifdef DIRSESSION
  357.     "dir",      dodir,      0, 0, NULLCHAR, /* note sequence */
  358. #endif
  359. #endif
  360. #ifdef DOSCMD
  361.     "delete",   dodelete,   0, 2, "delete <file>",
  362. #endif
  363.     "detach",   dodetach,   0, 2, "detach <interface>",
  364. #ifdef  DIALER
  365.     "dialer",       dodialer,       512, 2,
  366.     "dialer <iface> [<file> [<seconds> [<pings> [<hostid>]]]]",
  367. #endif
  368.     "domain",       dodomain,       0, 0, NULLCHAR,
  369. #ifdef  DRSI
  370.     "drsistat",     dodrstat,       0, 0, NULLCHAR,
  371. #endif
  372. #ifdef ALLCMD
  373.     "dump",     domdump,    0, 0, NULLCHAR,
  374. #endif
  375. #ifdef MAILERROR
  376.     "errors",   doerror,    0, 0, NULLCHAR,
  377. #endif
  378. #ifdef  HS
  379.     "hs",           dohs,           0, 0, NULLCHAR,
  380. #endif
  381. #ifdef  EAGLE
  382.     "eaglestat",    doegstat,       0, 0, NULLCHAR,
  383. #endif
  384.     "echo",         doecho,         0, 0, NULLCHAR,
  385.     "eol",          doeol,          0, 0, NULLCHAR,
  386. #if     (!defined(MSDOS) || defined(ESCAPE))
  387.     "escape",       doescape,       0, 0, NULLCHAR,
  388. #endif
  389. #ifdef  PC_EC
  390.     "etherstat",    doetherstat,    0, 0, NULLCHAR,
  391. #endif
  392.     "exit",         doexit,         0, 0, NULLCHAR,
  393. #ifdef EXPIRY
  394.     "expire",   doexpire,   0, 0, NULLCHAR,
  395. #endif
  396. #ifdef FINGERSESSION
  397.     "finger",   dofinger,   1024, 2, "finger name@host",
  398. #endif
  399. #ifdef ALLCMD
  400.     "fkey",         dofkey,         0, 0, NULLCHAR,
  401. #endif
  402. #ifdef FTPSESSION
  403.     "ftp",      doftp,      2048, 2, "ftp <address>",
  404.     "ftype",    doftype,    0, 0, NULLCHAR,
  405. #ifdef LZW
  406.     "ftpclzw",  doftpclzw,  0, 0, NULLCHAR,
  407.     "ftpslzw",  doftpslzw,  0, 0, NULLCHAR,
  408. #endif
  409. #endif
  410. #ifdef FTPSERVER
  411.     "ftptdisc", doftptdisc, 0, 0, NULLCHAR,
  412. #endif
  413. #ifdef HAPN
  414.     "hapnstat",     dohapnstat,     0, 0, NULLCHAR,
  415. #endif
  416.     "help",         dohelp,         0, 0, NULLCHAR,
  417.     "history",  dohistory,  0, 0, NULLCHAR,
  418. #ifdef HOPCHECKSESSION
  419.     "hop",          dohop,          0, 0, NULLCHAR,
  420. #endif
  421.     "hostname",     dohostname,     0, 0, NULLCHAR,
  422. #ifdef  HS
  423.     "hs",           dohs,           0, 0, NULLCHAR,
  424. #endif
  425.     "icmp",         doicmp,         0, 0, NULLCHAR,
  426.     "ifconfig",     doifconfig,     0, 0, NULLCHAR,
  427. #ifdef ALLCMD
  428.     "info",         doinfo,         0, 0, NULLCHAR,
  429. #endif
  430.     "index",        doindex,     2048, 2, "index <mailbox>",
  431.     "ip",           doip,           0, 0, NULLCHAR,
  432. #ifdef  MSDOS
  433.     "isat",         doisat,         0, 0, NULLCHAR,
  434. #endif
  435.     "kick",         dokick,         0, 0, NULLCHAR,
  436. #ifdef LOCK
  437.     "lock",         dolock,         0, 0, NULLCHAR,
  438. #endif
  439.     "log",      dolog,      0, 0, NULLCHAR,
  440. #ifdef LOOKSESSION
  441.     "look",     dolook,     1024, 2, "look <user|sock#>",
  442. #endif
  443. #ifdef LZW
  444.     "lzw",      dolzw,      0, 2, "lzw <mode|bits|trace>",
  445. #endif
  446. #ifdef ALLCMD
  447.     "mail",     dobmail,    0, 0, NULLCHAR,
  448. #endif
  449. #ifdef  MAILBOX
  450.     "mbox",         dombox,         0, 0, NULLCHAR,
  451. #endif
  452. #ifndef UNIX
  453.     "memory",       domem,          0, 0, NULLCHAR,
  454. #endif
  455. #ifdef DOSCMD
  456.     "mkdir",    domkd,      0, 2, "mkdir <directory>",
  457. #endif
  458. #ifdef  AX25
  459.     "mode",         domode,         0, 2, "mode <interface>",
  460. #endif
  461. #ifdef MORESESSION
  462.     "more",     domore,     0, 2, "more <file> [searchstring]",
  463. #endif
  464. #ifdef ALLCMD
  465.     "motd",         domotd,         0, 0, NULLCHAR,
  466. #endif
  467. #ifdef MSDOS
  468. #ifdef MULTITASK
  469.     "multitask",    dobackg,    0, 0, NULLCHAR,
  470. #endif
  471. #endif
  472. #ifdef NETROM
  473.     "netrom",       donetrom,       0, 0, NULLCHAR,
  474. #endif  /* NETROM */
  475. #if defined NNTP || defined NNTPS
  476.     "nntp",         donntp,         0, 0, NULLCHAR,
  477. #endif
  478. #ifdef NRS
  479.     "nrstat",       donrstat,       0, 0, NULLCHAR,
  480. #endif
  481. #ifdef EXPIRY
  482.     "oldbid",   dooldbids,  0, 0, NULLCHAR,
  483. #endif
  484.     "param",        doparam,        0, 2, "param <interface>",
  485.     "pause",        dopause,        0, 0, NULLCHAR,
  486. #ifdef PINGSESSION
  487.     "ping",         doping,         512, 2,
  488.     "ping <hostid> [<length> [<interval> [incflag]]]",
  489. #endif
  490. #ifdef PI
  491.     "pistatus",     dopistat,       0, 0, NULLCHAR,
  492. #endif
  493. #ifdef MAILCLIENT
  494.     "popmail",      domsread,       0, 0, NULLCHAR,
  495. #endif
  496. #ifdef PPP
  497.     "ppp",          doppp_commands, 0, 0, NULLCHAR,
  498. #endif
  499.     "prompt",   doprompt,   0, 0, NULLCHAR,
  500.     "ps",           ps,             0, 0, NULLCHAR,
  501. #if !defined(UNIX) && !defined(AMIGA)
  502. #ifdef DOSCMD
  503.     "pwd",      docd,       0, 0, NULLCHAR,
  504. #endif
  505. #endif
  506. #if (defined(AX25) || defined(ETHER))
  507. #ifdef RARP
  508.     "rarp",     dorarp,     0, 0, NULLCHAR,
  509. #endif /* RARP */
  510. #endif
  511. #ifdef RDATE
  512.     "rdate",    dordate,    0, 0, NULLCHAR,
  513. #endif
  514. #ifdef ALLCMD
  515.     "record",   dorecord,   0, 0, NULLCHAR,
  516. #endif
  517.     "remote",   doremote,   0, 3, "remote [-p port] [-k key] [-a kickaddr] <address> exit|reset|kick",
  518. #ifdef DOSCMD
  519.     "rename",   dorename,   0, 3, "rename <oldfile> <newfile>",
  520. #endif
  521. #ifdef REPEATSESSION
  522.     "repeat",   dorepeat, 512, 3, "repeat <interval> <command> [args...]",
  523. #endif
  524.     "reset",    doreset,    0, 0, NULLCHAR,
  525.     "rewrite",  dorewrite,  0, 2, "rewrite <address>",
  526. #ifdef  RIP
  527.     "rip",          dorip,          0, 0, NULLCHAR,
  528. #endif
  529. #ifdef RLOGINSESSION
  530.     "rlogin",       dorlogin,       2048, 2, "rlogin <address>",
  531. #endif
  532. #ifdef DOSCMD
  533.     "rmdir",    dormd,      0, 2, "rmdir <directory>",
  534. #endif
  535.     "route",    doroute,    0, 0, NULLCHAR,
  536. #ifdef  RSPF
  537.     "rspf",         dorspf,         0, 0, NULLCHAR,
  538. #endif  /* RSPF */
  539. #ifdef SESSIONS
  540.     "session",      dosession,      0, 0, NULLCHAR,
  541. #endif
  542. #ifdef  SCC
  543.     "sccstat",      dosccstat,      0, 0, NULLCHAR,
  544. #endif
  545. #if     !defined(AMIGA)
  546. #ifdef SHELL
  547.     "shell",    doshell,    0, 0, NULLCHAR,
  548. #endif
  549. #endif
  550.     "skick",    dokicksocket,0,2, "skick <socket#>",
  551.     "smtp",     dosmtp,     0, 0, NULLCHAR,
  552.     "socket",       dosock,         0, 0, NULLCHAR,
  553.     "source",       dosource,       0, 2, "source <filename>",
  554. #ifdef SERVERS
  555.     "start",        dostart,        0, 2, "start <servername>",
  556.     "stop",         dostop,         0, 2, "stop <servername>",
  557. #endif
  558.     "status",   dostatus,   0, 0, NULLCHAR,
  559. #if defined  AX25SESSION && defined SPLITSCREEN
  560.     "split",    doconnect,  1024, 3, "split <interface> <callsign>",
  561. #endif
  562.     "tcp",      dotcp,      0, 0, NULLCHAR,
  563. #ifdef ALLCMD
  564.     "tail",     dotail,     0, 2, "tail <filename>",
  565.     "taillog",  dotaillog,  0, 0, NULLCHAR,
  566. #endif
  567. #ifdef TELNETSESSION
  568.     "telnet",   dotelnet,   1024, 2, "telnet <address> [port]",
  569. #endif
  570. #ifdef TTYLINKSESSION
  571.     "ttylink",  dotelnet,  1024, 2, "ttylink <address> [port]",
  572. #endif
  573. #ifdef  MAILBOX
  574.     "third-party",  dothirdparty,   0, 0, NULLCHAR,
  575. #endif
  576. #ifdef TIPSESSION
  577.     "tip",      dotip,      256, 2, "tip <iface (asyc only!)>",
  578. #endif
  579. #ifdef  PACKETWIN
  580.     "tsync_stat",   do_tsync_stat,  0, 0, NULLCHAR,
  581.     "tsydump",              do_tsync_dump,  0, 2, "tsydump <channel>",
  582. #endif
  583. #ifdef  TRACE
  584.     "trace",        dotrace,        0, 0, NULLCHAR,
  585.     "strace",   dostrace,   0, 0, NULLCHAR,
  586. #endif
  587.     "udp",          doudp,          0, 0, NULLCHAR,
  588. #ifdef ALLCMD
  589.     "upload",   doupload,   0, 0, NULLCHAR,
  590. #endif
  591. #ifdef  MSDOS
  592. #ifdef ALLCMD
  593. #ifdef SWATCH
  594.     "watch",    doswatch,   0, 0, NULLCHAR,
  595. #endif
  596. #endif
  597.     "watchdog", dowatchdog, 0, 0, NULLCHAR,
  598. #endif
  599.     "write",    dowrite,    0, 3, "write <user|sock#> <msg>",
  600. #ifdef MAILBOX
  601.     "writeall", dowriteall, 0, 2, "writeall <msg>",
  602. #endif
  603.     "?",        dohelp,     0, 0, NULLCHAR,
  604.     NULLCHAR,       NULLFP,         0, 0,
  605.     "Unknown command; type \"?\" for list",
  606. };
  607.  
  608. extern int at_attach();
  609.  
  610. /* List of supported hardware devices */
  611. struct cmds DFAR Attab[] = {
  612.  
  613. #ifdef  PC_EC
  614.     /* 3-Com Ethernet interface */
  615.     "3c500", ec_attach, 0, 7,
  616.     "attach 3c500 <address> <vector> arpa <label> <buffers> <mtu> [ip_addr]",
  617. #endif
  618.  
  619. #ifdef  ASY
  620.     /* Ordinary PC asynchronous adaptor */
  621.     "asy",  asy_attach, 0, 8,
  622.     "attach asy <address> <vector> "
  623.  
  624. #ifdef SLIP
  625.     "slip"
  626. #endif
  627.  
  628. #ifdef AX25
  629. #ifdef SLIP
  630.     "|"
  631. #endif
  632.     "ax25"
  633. #endif
  634.  
  635. #ifdef NRS
  636. #if ((defined SLIP) || (defined AX25))
  637.     "|"
  638. #endif
  639.     "nrs"
  640. #endif
  641.  
  642. #ifdef POLLEDKISS
  643. #if ((defined SLIP) || (defined AX25) || (defined NRS))
  644.     "|"
  645. #endif
  646.     "|pkiss"
  647. #endif
  648.  
  649. #ifdef PPP
  650. #if ((defined SLIP) || (defined AX25) || (defined NRS) || (defined POLLEDKISS))
  651.     "|"
  652. #endif
  653.     "|ppp"
  654. #endif
  655.  
  656.     " <label> <buffers> <mtu> <speed> [options]",
  657. #endif  /* ASY */
  658.  
  659. #ifdef BPQ
  660.     /* g8bpq_host */
  661.     "bpq", bpq_attach, 0, 3,
  662.     "attach bpq init <vec> <stream>\n"
  663.     "attach bpq <port> <label> [mtu] [callsign]",
  664. #endif
  665.  
  666. #ifdef  KISS
  667.     /* Multi-port KISS interface piggy-backing on ASY interface. */
  668.     "kiss", kiss_attach, 0, 4,
  669.     "attach kiss <asy_interface_label> <port> <label> [mtu]",
  670. #endif  /* KISS */
  671.  
  672. #ifdef  PC100
  673.     /* PACCOMM PC-100 8530 HDLC adaptor */
  674.     "pc100", pc_attach, 0, 8,
  675.     "attach pc100 <address> <vector> ax25 <label> <buffers>\
  676.     <mtu> <speed> [ip_addra] [ip_addrb]",
  677. #endif
  678.  
  679. #ifdef  DRSI
  680.     /* DRSI PCPA card in low speed mode */
  681.     "drsi", dr_attach, 0, 8,
  682.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu>\
  683.     <chan a speed> <chan b speed> [ip addr a] [ip addr b]",
  684. #endif
  685.  
  686. #ifdef  EAGLE
  687.     /* EAGLE RS-232C 8530 HDLC adaptor */
  688.     "eagle", eg_attach, 0, 8,
  689.     "attach eagle <address> <vector> ax25 <label> <buffers>\
  690.     <mtu> <speed> [ip_addra] [ip_addrb]",
  691. #endif
  692.  
  693. #ifdef  HAPN
  694.     /* Hamilton Area Packet Radio (HAPN) 8273 HDLC adaptor */
  695.     "hapn", hapn_attach, 0, 8,
  696.     "attach hapn <address> <vector> ax25 <label> <rx bufsize>\
  697.     <mtu> csma|full [ip_addr]",
  698. #endif
  699.  
  700. #ifdef  APPLETALK
  701.     /* Macintosh AppleTalk */
  702.     "0", at_attach, 0, 7,
  703.     "attach 0 <protocol type> <device> arpa <label> <rx bufsize> <mtu> [ip_addr]",
  704. #endif
  705.  
  706. #ifdef NETROM
  707.     /* fake netrom interface */
  708.     "netrom", nr_attach, 0, 1,
  709.     "attach netrom [ip_addr]",
  710. #endif
  711.  
  712. #ifdef  PACKET
  713.     /* FTP Software's packet driver spec */
  714.     "packet", pk_attach, 0, 4,
  715.     "attach packet <int#> <label> <buffers> <mtu> [ip_addr]",
  716. #endif
  717.  
  718. #ifdef  HS
  719.     /* Special high speed driver for DRSI PCPA or Eagle cards */
  720.     "hs", hs_attach, 0, 7,
  721.     "attach hs <address> <vector> ax25 <label> <buffers> <mtu>\
  722.     <txdelay> <persistence> [ip_addra] [ip_addrb]",
  723. #endif
  724.  
  725. #ifdef  PI
  726.     /* Special high speed driver for PI 8530 HDLC adapter */
  727.     "pi", pi_attach, 0, 8,
  728.     "attach pi <address> <vector> <dmachannel> ax25 <label> <buffers>\
  729.     <mtu> <speed a> <speed b> [ip_addra] [ip_addrb]",
  730. #endif
  731.  
  732. #ifdef SCC
  733.     "scc", scc_attach, 0, 7,
  734.     "attach scc <devices> init <addr> <spacing> <Aoff> <Boff> <Dataoff>\n"
  735.     "   <intack> <vec> [p]<clock> [hdwe] [param]\n"
  736.     "attach scc <chan> slip|kiss|nrs|ax25 <label> <mtu> <speed> <bufsize> [call] ",
  737. #endif
  738.  
  739. #ifdef  PACKETWIN
  740.     /* Gracilis PackeTwin */
  741.     "tsync", tsync_attach, 0, 11,
  742.     "attach tsync <chan> <vec> <iobase> <hdx|fdx> <dma|ints> <rxdmachan> <name> <rxsize> <txsize> <speed> [txclk] [rxclk] [nrz|nrzi] [ipaddr] [#rxbufs]",
  743. #endif
  744.  
  745. #ifdef AXIP
  746.     "axip",axip_attach, 0, 4,
  747.     "attach axip <name> <mtu> <remote-hostid> [callsign]",
  748. #endif
  749.  
  750.     NULLCHAR,
  751. };
  752.  
  753. #ifndef LINUX
  754.  
  755. /* Functions to be called on each clock tick */
  756. void (*Cfunc[]) __ARGS((void)) = {
  757.     pctick, /* Call PC-specific stuff to keep time */
  758.     kbint,  /* Necessary because there's no hardware keyboard interrupt */
  759.     refiq,  /* Replenish interrupt pool */
  760. #ifdef  ASY
  761.     asytimer,
  762. #endif
  763. #ifdef  SCC
  764.     scctimer,
  765. #endif
  766. #ifdef BPQ
  767.     bpqtimer,
  768. #endif
  769.     NULL,
  770. };
  771.  
  772. /* Entry points for garbage collection */
  773. void (*Gcollect[]) __ARGS((int)) = {
  774.     tcp_garbage,
  775.     ip_garbage,
  776.     udp_garbage,
  777.     st_garbage,
  778. #ifdef  AX25
  779.     lapb_garbage,
  780. #endif
  781. #ifdef  NETROM
  782.     nr_garbage,
  783. #endif
  784.     NULL
  785. };
  786.  
  787. /* Functions to be called at shutdown */
  788. void (*Shutdown[])() = {
  789. #ifdef SCC
  790.     sccstop,
  791. #endif
  792.     uchtimer,       /* Unlink timer handler from timer chain */
  793.     NULLVFP,
  794. };
  795.  
  796. #endif /* LINUX */
  797.  
  798. /* Packet tracing stuff */
  799. #ifdef  TRACE
  800. #include "trace.h"
  801.  
  802. extern int at_forus();
  803. extern void at_dump();
  804.  
  805. /* Protocol tracing function pointers. Matches list of class definitions
  806.  * in pktdrvr.h.
  807.  */
  808. struct trace Tracef[] = {
  809.     NULLFP,         ip_dump,        /* CL_NONE */
  810.  
  811. #ifdef  ETHER                           /* CL_ETHERNET */
  812.     ether_forus,    ether_dump,
  813. #else
  814.     NULLFP,         NULLVFP,
  815. #endif  /* ETHER */
  816.  
  817.     NULLFP,         NULLVFP,        /* CL_PRONET_10 */
  818.     NULLFP,         NULLVFP,        /* CL_IEEE8025 */
  819.     NULLFP,         NULLVFP,        /* CL_OMNINET */
  820.  
  821. #ifdef  APPLETALK
  822.     at_forus,       at_dump,        /* CL_APPLETALK */
  823. #else
  824.     NULLFP,         NULLVFP,
  825. #endif  /* APPLETALK */
  826.  
  827. #ifdef VJCOMPRESS
  828.     NULLFP,         sl_dump,        /* CL_SERIAL_LINE */
  829. #else
  830.     NULLFP,         ip_dump,        /* CL_SERIAL_LINE */
  831. #endif
  832.     NULLFP,         NULLVFP,        /* CL_STARLAN */
  833.  
  834. #ifdef  ARCNET
  835.     arc_forus,      arc_dump,       /* CL_ARCNET */
  836. #else
  837.     NULLFP,         NULLVFP,
  838. #endif  /* ARCNET */
  839.  
  840. #ifdef  AX25
  841.     ax_forus,       ax25_dump,      /* CL_AX25 */
  842. #else
  843.     NULLFP,         NULLVFP,
  844. #endif  /* AX25 */
  845.  
  846. #ifdef  AX25                           /* CL_KISS */
  847.     ki_forus,       ki_dump,
  848. #else
  849.     NULLFP,         NULLVFP,
  850. #endif  /* KISS */
  851.  
  852.     NULLFP,         NULLVFP,        /* CL_IEEE8023 */
  853.     NULLFP,         NULLVFP,        /* CL_FDDI */
  854.     NULLFP,         NULLVFP,        /* CL_INTERNET_X25 */
  855.     NULLFP,         NULLVFP,        /* CL_LANSTAR */
  856. #ifdef  SLFP
  857.     NULLFP,         ip_dump,        /* CL_SLFP */
  858. #else
  859.     NULLFP,         NULLVFP,
  860. #endif  /* SLFP */
  861.  
  862. #ifdef  NETROM                          /* CL_NETROM */
  863.     NULLFP,         ip_dump,
  864. #else
  865.     NULLFP,         NULLVFP,
  866. #endif
  867.  
  868. #ifdef PPP
  869.     NULLFP,         ppp_dump,       /* CL_PPP */
  870. #else
  871.     NULLFP,         NULLVFP,
  872. #endif /* PPP */
  873. };
  874.  
  875. #else
  876.  
  877. /* Stub for packet dump function */
  878. void
  879. dump(iface,direction,type,bp)
  880. struct iface *iface;
  881. int direction;
  882. unsigned type;
  883. struct mbuf *bp;
  884. {
  885. }
  886. void
  887. raw_dump(iface,direction,bp)
  888. struct iface *iface;
  889. int direction;
  890. struct mbuf *bp;
  891. {
  892. }
  893.  
  894. #endif  /* TRACE */
  895.  
  896.  
  897. #ifdef  AX25
  898. #ifdef AUTOROUTE
  899. /* G4JEC's automatic ARP & Route resolution code primitive. */
  900. extern void ax25eavesdrop(struct iface * iface,
  901. char *source, char * dest,
  902. struct mbuf * bp);
  903.  
  904. extern int Ax25_autoroute;
  905. #endif /* AUTOROUTE */
  906.  
  907. /* Hooks for passing incoming AX.25 data frames to network protocols */
  908. void
  909. axip(iface,axp,src,dest,bp,mcast)
  910. struct iface *iface;
  911. struct ax25_cb *axp;
  912. char *src;
  913. char *dest;
  914. struct mbuf *bp;
  915. int mcast;
  916. {
  917. #ifdef AUTOROUTE
  918.     struct mbuf *nbp;
  919.  
  920.     if(Ax25_autoroute) {
  921.         dup_p(&nbp, bp, 0, len_p(bp));
  922.         (void) ax25eavesdrop(iface,src,dest,nbp);
  923.         free_p(nbp);
  924.     }
  925. #endif
  926.     (void)ip_route(iface,bp,mcast);
  927. }
  928.  
  929. static void
  930. axarp(iface,axp,src,dest,bp,mcast)
  931. struct iface *iface;
  932. struct ax25_cb *axp;
  933. char *src;
  934. char *dest;
  935. struct mbuf *bp;
  936. int mcast;
  937. {
  938.     (void)arp_input(iface,bp);
  939. }
  940.  
  941. #ifdef RARP
  942. static void
  943. axrarp(iface,axp,src,dest,bp,mcast)
  944. struct iface *iface;
  945. struct ax25_cb *axp;
  946. char *src;
  947. char *dest;
  948. struct mbuf *bp;
  949. int mcast;
  950. {
  951.     (void)rarp_input(iface,bp);
  952. }
  953. #endif /* RARP */
  954.  
  955. #ifdef  NETROM
  956. static void
  957. axnr(iface,axp,src,dest,bp,mcast)
  958. struct iface *iface;
  959. struct ax25_cb *axp;
  960. char *src;
  961. char *dest;
  962. struct mbuf *bp;
  963. int mcast;
  964. {
  965.     if(!mcast)
  966.         nr_route(bp,axp);
  967.     else
  968.         nr_nodercv(iface,src,bp);
  969. }
  970.  
  971. #endif  /* NETROM */
  972. #endif  /* AX25 */
  973.  
  974. #ifndef RIP
  975. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  976. void
  977. rt_timeout(s)
  978. void *s;
  979. {
  980.     struct route *stale = (struct route *)s;
  981.  
  982.     rt_drop(stale->target,stale->bits);
  983. }
  984. #endif
  985.  
  986. #ifdef  SERVERS
  987. #define SSTACK 160      /* servers stack size */
  988. /* "start" and "stop" subcommands */
  989. static struct cmds DFAR Startcmds[] = {
  990. #ifdef AX25SERVER
  991.     "ax25",         ax25start,      SSTACK, 0, NULLCHAR,
  992. #endif
  993. #if defined CALLSERVER || defined SAMCALLB || defined QRZCALLB
  994.     "callbook",     cdbstart,       SSTACK, 0, NULLCHAR,
  995. #endif
  996. #ifdef  CONVERS
  997.     "convers",      conv1,          0, 0, NULLCHAR,
  998. #endif
  999. #ifdef DISCARDSERVER
  1000.     "discard",      dis1,           0, 0, NULLCHAR,
  1001. #endif
  1002. #ifdef ECHOSERVER
  1003.     "echo",         echo1,          0, 0, NULLCHAR,
  1004. #endif
  1005. #ifdef FINGERSERVER
  1006.     "finger",       finstart,       0, 0, NULLCHAR,
  1007. #endif
  1008. #ifdef FTPSERVER
  1009.     "ftp",          ftpstart,       0, 0, NULLCHAR,
  1010. #endif
  1011. #if defined(MBFWD) && defined(MAILBOX)
  1012.     "forward",      fwdstart,       2048,0, NULLCHAR,
  1013. #endif
  1014. #ifdef NETROMSERVER
  1015.     "netrom",       nr4start,       SSTACK, 0, NULLCHAR,
  1016. #endif
  1017. #ifdef  NNTPS
  1018.     "nntp",         nntp1,          0, 0, NULLCHAR,
  1019. #endif
  1020. #ifdef  POP2SERVER
  1021.     "pop2",         pop2start,      0, 0, NULLCHAR,
  1022. #endif
  1023. #ifdef  POP3SERVER
  1024.     "pop3",         pop3start,      0, 0, NULLCHAR,
  1025. #endif
  1026. #ifdef  RIP
  1027.     "rip",          doripinit,      0,   0, NULLCHAR,
  1028. #endif
  1029. #ifdef RLOGINSERVER
  1030.        "rlogin",       rlogin1,   SSTACK, 0, NULLCHAR,
  1031. #endif
  1032. #ifdef SMTPSERVER
  1033.     "smtp",         smtp1,          0, 0, NULLCHAR,
  1034. #endif
  1035. #ifdef TELNETSERVER
  1036.     "telnet",       telnet1,        0, 0, NULLCHAR,
  1037. #endif
  1038. #ifdef TIPSERVER
  1039.     "tip",          tipstart,       384, 2, "start tip <interface>",
  1040. #endif
  1041. #ifdef  RDATE
  1042.     "time",         time1,          0, 0, NULLCHAR,
  1043. #endif
  1044. #ifdef TTYLINKSERVER
  1045.     "ttylink",      ttylstart,      0, 0, NULLCHAR,
  1046. #endif
  1047. #ifdef REMOTESERVER
  1048.     "remote",       rem1,           768, 0, NULLCHAR,
  1049. #endif
  1050.     NULLCHAR,
  1051. };
  1052.  
  1053. static struct cmds DFAR Stopcmds[] = {
  1054. #ifdef AX25SERVER
  1055.     "ax25",         ax250,          0, 0, NULLCHAR,
  1056. #endif
  1057. #if defined CALLSERVER || defined SAMCALLB || defined QRZCALLB
  1058.     "callbook",     cdb0,           0, 0, NULLCHAR,
  1059. #endif
  1060. #ifdef  CONVERS
  1061.     "convers",  conv0,      0, 0, NULLCHAR,
  1062. #endif
  1063. #ifdef DISCARDSERVER
  1064.     "discard",  dis0,       0, 0, NULLCHAR,
  1065. #endif
  1066. #ifdef ECHOSERVER
  1067.     "echo",         echo0,          0, 0, NULLCHAR,
  1068. #endif
  1069. #ifdef FINGERSERVER
  1070.     "finger",   fin0,       0, 0, NULLCHAR,
  1071. #endif
  1072. #ifdef FTPSERVER
  1073.     "ftp",          ftp0,           0, 0, NULLCHAR,
  1074. #endif
  1075. #if defined(MBFWD) && defined(MAILBOX)
  1076.     "forward",  fwd0,       0, 0, NULLCHAR,
  1077. #endif
  1078. #ifdef NETROMSERVER
  1079.     "netrom",       nr40,           0, 0, NULLCHAR,
  1080. #endif
  1081. #ifdef  NNTPS
  1082.     "nntp",     nntp0,      0, 0, NULLCHAR,
  1083. #endif
  1084. #ifdef  POP2SERVER
  1085.     "pop2",         pop2stop,       0, 0, NULLCHAR,
  1086. #endif
  1087. #ifdef  POP3SERVER
  1088.     "pop3",         pop3stop,       0, 0, NULLCHAR,
  1089. #endif
  1090. #ifdef  RIP
  1091.     "rip",          doripstop,      0, 0, NULLCHAR,
  1092. #endif
  1093. #ifdef RLOGINSERVER
  1094.         "rlogin",       rlogin0,        0, 0, NULLCHAR,
  1095. #endif
  1096. #ifdef SMTPSERVER
  1097.     "smtp",         smtp0,          0, 0, NULLCHAR,
  1098. #endif
  1099. #ifdef TELNETSERVER
  1100.     "telnet",       telnet0,        0, 0, NULLCHAR,
  1101. #endif
  1102. #ifdef TIPSERVER
  1103.     "tip",      tip0,       0, 2, "stop tip <interface>",
  1104. #endif
  1105. #ifdef  RDATE
  1106.     "time",     time0,      0, 0, NULLCHAR,
  1107. #endif
  1108. #ifdef TTYLINKSERVER
  1109.     "ttylink",  ttyl0,      0, 0, NULLCHAR,
  1110. #endif
  1111. #ifdef REMOTESERVER
  1112.     "remote",   rem0,       0, 0, NULLCHAR,
  1113. #endif
  1114.     NULLCHAR,
  1115.  
  1116. };
  1117.  
  1118. /* TCP port numbers to be considered "interactive" by the IP routing
  1119.  * code and given priority in queueing
  1120.  */
  1121. int Tcp_interact[] = {
  1122.     IPPORT_FTP, /* FTP control (not data!) */
  1123.     IPPORT_TELNET,  /* Telnet */
  1124.     IPPORT_CONVERS, /* Convers */
  1125.     IPPORT_XCONVERS,    /* LZW Convers */
  1126.     IPPORT_TTYLINK,     /* Tty link */
  1127.     IPPORT_RLOGIN,      /* BSD rlogin */
  1128.     IPPORT_MTP,         /* Secondary telnet */
  1129.     -1
  1130. };
  1131.  
  1132. static int
  1133. dostart(argc,argv,p)
  1134. int argc;
  1135. char *argv[];
  1136. void *p;
  1137. {
  1138.     int ret,insave,outsave;
  1139.  
  1140.     insave = Curproc->input;
  1141.     outsave = Curproc->output;
  1142.     Curproc->input = Cmdpp->input;
  1143.     Curproc->output = Cmdpp->output;
  1144.  
  1145.     ret = subcmd(Startcmds,argc,argv,p);
  1146.  
  1147.     Curproc->input = insave;
  1148.     Curproc->output = outsave;
  1149.     return ret;
  1150. }
  1151.  
  1152. static int
  1153. dostop(argc,argv,p)
  1154. int argc;
  1155. char *argv[];
  1156. void *p;
  1157. {
  1158.     return subcmd(Stopcmds,argc,argv,p);
  1159. }
  1160. #endif  /* SERVERS */
  1161.  
  1162. /* Various configuration-dependent functions */
  1163.  
  1164. /* put mbuf into Hopper for network task
  1165.  * returns 0 if OK
  1166.  */
  1167. int
  1168. net_route(ifp, type, bp)
  1169. struct iface *ifp;
  1170. int type;
  1171. struct mbuf *bp;
  1172. {
  1173.     struct mbuf *nbp;
  1174.     struct phdr phdr;
  1175.  
  1176.     phdr.iface = ifp;
  1177.     phdr.type = type;
  1178.  
  1179.     if ((nbp = pushdown(bp,sizeof(phdr))) == NULLBUF ){
  1180.         return -1;
  1181.     }
  1182.     memcpy( &nbp->data[0],(char *)&phdr,sizeof(phdr));
  1183.     enqueue(&Hopper,nbp);
  1184.     /* Especially on slow machines, serial I/O can be quite
  1185.      * compute intensive, so release the machine before we
  1186.      * do the next packet.  This will allow this packet to
  1187.      * go on toward its ultimate destination. [Karn]
  1188.      */
  1189.     pwait(NULL);
  1190.     return 0;
  1191. }
  1192.  
  1193. /* Process packets in the Hopper */
  1194. static void
  1195. network(i,v1,v2)
  1196. int i;
  1197. void *v1;
  1198. void *v2;
  1199. {
  1200.     struct mbuf *bp;
  1201.     struct phdr phdr;
  1202.     int i_state;
  1203.  
  1204.     loop:
  1205. #ifndef LINUX
  1206.     refiq();        /* Replenish interrupt buffer pool */
  1207. #endif
  1208.  
  1209.     i_state = dirps();
  1210.     while(Hopper == NULLBUF)
  1211.         pwait(&Hopper);
  1212.  
  1213.     /* this is silly, first we turn ints on, then off again...? -WG7J */
  1214.     /* Process the input packet */
  1215.     /*
  1216.     bp = dequeue(&Hopper);
  1217.      */
  1218.  
  1219.     bp = Hopper;
  1220.     Hopper = Hopper->anext;
  1221.     bp->anext = NULLBUF;
  1222.  
  1223.     restore(i_state);
  1224.  
  1225.     pullup(&bp,(char *)&phdr,sizeof(phdr));
  1226.     if(phdr.iface != NULLIF){
  1227.         phdr.iface->rawrecvcnt++;
  1228.         phdr.iface->lastrecv = secclock();
  1229.     }
  1230. #ifdef TRACE
  1231.     dump(phdr.iface,IF_TRACE_IN,phdr.type,bp);
  1232. #endif
  1233.     switch(phdr.type){
  1234. #if((defined KISS) || (defined AX25))
  1235.         case CL_KISS:
  1236.             kiss_recv(phdr.iface,bp);
  1237.             break;
  1238. #endif
  1239. #ifdef  AX25
  1240.         case CL_AX25:
  1241.             ax_recv(phdr.iface,bp);
  1242.             break;
  1243. #endif
  1244. #ifdef  ETHER
  1245.         case CL_ETHERNET:
  1246.             eproc(phdr.iface,bp);
  1247.             break;
  1248. #endif
  1249. #ifdef ARCNET
  1250.         case CL_ARCNET:
  1251.             aproc(phdr.iface,bp);
  1252.             break;
  1253. #endif
  1254. #ifdef PPP
  1255.         case CL_PPP:
  1256.             ppp_proc(phdr.iface,bp);
  1257.             break;
  1258. #endif
  1259.     /* These types have no link layer protocol at the point when they're
  1260.      * put in the hopper, so they can be handed directly to IP. The
  1261.      * separate types are just for user convenience when running the
  1262.      * "iface" command.
  1263.      */
  1264.         case CL_NONE:
  1265.         case CL_SERIAL_LINE:
  1266.         case CL_SLFP:
  1267.             ip_route(phdr.iface,bp,0);
  1268.             break;
  1269.         default:
  1270.             free_p(bp);
  1271.             break;
  1272.     }
  1273.     /* Let everything else run - this keeps the system from wedging
  1274.      * when we're hit by a big burst of packets
  1275.      */
  1276.     pwait(NULL);
  1277.     goto loop;
  1278. }
  1279.  
  1280. #ifdef notdef
  1281.  
  1282. /*
  1283.  * General purpose interface transmit task, one for each device that can
  1284.  * send IP datagrams. It waits on the interface's IP output queue (outq),
  1285.  * extracts IP datagrams placed there in priority order by ip_route(),
  1286.  * and sends them to the device's send routine.
  1287.  */
  1288. void
  1289. if_tx(dev,arg1,unused)
  1290. int dev;
  1291. void *arg1;
  1292. void *unused;
  1293. {
  1294.     struct mbuf *bp;    /* Buffer to send */
  1295.     struct iface *iface;    /* Pointer to interface control block */
  1296.     struct qhdr qhdr;
  1297.  
  1298.     iface = arg1;
  1299.     for(;;){
  1300.         while(iface->outq == NULLBUF)
  1301.             pwait(&iface->outq);
  1302.  
  1303.         iface->txbusy = 1;
  1304.         bp = dequeue(&iface->outq);
  1305.         pullup(&bp,(char *)&qhdr,sizeof(qhdr));
  1306.         (*iface->send)(bp,iface,qhdr.gateway,qhdr.tos);
  1307.         iface->txbusy = 0;
  1308.  
  1309.         /* Let other tasks run, just in case send didn't block */
  1310.         pwait(NULL);
  1311.     }
  1312. }
  1313.  
  1314. #endif
  1315.